import threading
import mysql.connector


def insert_line(file_path):
	print("execute file-->", file_path)
	conn = mysql.connector.connect(host='192.168.2.159', port='3300', database='znzj', user='cincc',
								   password='cinCC1234',
								   use_unicode=True)
	c = conn.cursor()

	with open(file_path, 'r', encoding='utf-8') as f:
		for line in f.readlines():
			if len(line) < 2:
				continue
			c.execute('insert into txt(`id`, `txt`) values (null, %s);', (line.strip(),))
			conn.commit()
	c.close()
	conn.close()
	print("execute file success-->", file_path)


t1 = threading.Thread(target=insert_line, args=("F:\\txt\\wffs.txt",), name='LoopThread1')
t2 = threading.Thread(target=insert_line, args=("F:\\txt\\js.txt",), name='LoopThread2')
t3 = threading.Thread(target=insert_line, args=("F:\\txt\\jstm.txt",), name='LoopThread2')
t4 = threading.Thread(target=insert_line, args=("F:\\txt\\tsxk.txt",), name='LoopThread2')
t5 = threading.Thread(target=insert_line, args=("F:\\txt\\xylz.txt",), name='LoopThread2')
t6 = threading.Thread(target=insert_line, args=("F:\\txt\\ztj.txt",), name='LoopThread2')

t1.start()
t2.start()
t3.start()
t4.start()
t5.start()
t6.start()
